<?php

namespace app\admin\model\from;

use think\Model;
use think\Cache;
class Promote extends Model
{
    // 表名
    protected $name = 'from_promote';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $resultSetType = 'collection';
    // 追加属性
    protected $append = [
        'grade_text',
        'teacher_grade_text',
        'message_text',   
        'receive_text',     
    ];
     public function getReceiveList() {
        return ['1' => __('Receive 1'),'2' => __('Receive 2')];
    }     

    public function getReceiveTextAttr($value, $data) {     
         if(!isset($data['receive'])) return '';   
        $value = $value ? $value : $data['receive'];
        $list = $this->getReceiveList();
        return isset($list[$value]) ? $list[$value] : '';
    }      
     public function getMessageList()
    {
        return ['1' => __('Message_status 1'),'2' => __('Message_status 2')];
    }     


    public function getMessageTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['message_status'];
        $list = $this->getMessageList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    public function getGradeList()
    {
        return ['1' => __('Grade 1'),'2' => __('Grade 2'),'3' => __('Grade 3'),'4' => __('Grade 4'),'5' => __('Grade 5'),'6' => __('Grade 6')];
    }     

    public function getTeacherGradeList()
    {
        return ['1' => __('Teacher_grade 1'),'2' => __('Teacher_grade 2'),'3' => __('Teacher_grade 3'),'4' => __('Teacher_grade 4'),'5' => __('Teacher_grade 5'),'6' => __('Teacher_grade 6')];
    }     


    public function getGradeTextAttr($value, $data)
    {   
        if(!isset($data['grade'])) return '';     
        $value = $value ? $value : $data['grade'];
        $list = $this->getGradeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTeacherGradeTextAttr($value, $data)
    {   
        if(!isset($data['teacher_grade'])) return '';       
        $value = $value ? $value : $data['teacher_grade'];
        $list = $this->getTeacherGradeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

}
